﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Net;
using System.Net.Mail;
using System.Net.Mime;

namespace mark
{
    class Class2
    {


        public void send(String SendTo, String path, String mess)
        {
            SmtpClient Smtp = new SmtpClient("smtp.mail.ru", 25);
            Smtp.Credentials = new NetworkCredential("natal512", "112358");
            //Smtp.EnableSsl = false;

            //Формирование письма
            MailMessage Message = new MailMessage();
            Message.From = new MailAddress("natal512@mail.ru");
            Message.To.Add(new MailAddress(SendTo));
            Message.Subject = mess;
            Message.Body = mess;

            //Прикрепляем файл
            string file = path;
            Attachment attach = new Attachment(file, MediaTypeNames.Application.Octet);

            // Добавляем информацию для файла
            ContentDisposition disposition = attach.ContentDisposition;
            disposition.CreationDate = System.IO.File.GetCreationTime(file);
            disposition.ModificationDate = System.IO.File.GetLastWriteTime(file);
            disposition.ReadDate = System.IO.File.GetLastAccessTime(file);

            Message.Attachments.Add(attach);

            Smtp.Send(Message);//отправка
        }
    }

}